package com.oneinlet.service;

import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;

/**
 * Created by WangZiHe on 2017/11/5
 * QQ/WeChat:648830605
 * QQ-Group:368512253
 * Blog:www.520code.net
 * Github:https://github.com/yancheng199287
 */
public  interface IBaseService<T, ID extends Serializable> {
    @NotNull
     List<T> findAll();

    @NotNull
     List<T> findAll(@NotNull Sort paramSort);

    @NotNull
     List<T> findAllById(@NotNull Iterable<ID> paramIterable);

    @NotNull
     Page<T> findAll(@NotNull Pageable paramPageable);

    @NotNull
     <S extends T> Page<S> findAll(@NotNull Example<S> paramExample, @NotNull Pageable paramPageable);

    @NotNull
     <S extends T> List<S> findAll(@NotNull Example<S> paramExample);

    @NotNull
     <S extends T> List<S> findAll(@NotNull Example<S> paramExample, @NotNull Sort paramSort);

    @NotNull
     <S extends T> List<S> save(@NotNull Iterable<S> paramIterable);

     <S extends T> S save(S paramS);

     void flush();

     <S extends T> S saveAndFlush(S paramS);

     void deleteById(ID id);

     void delete(T t);

     void deleteInBatch(@NotNull Iterable<T> paramIterable);

     void deleteAllInBatch();

     T getOne(@NotNull ID paramID);

     Optional<T> findOne(@NotNull ID paramID);

     <S extends T> Optional<S> findOne(@NotNull Example<S> paramExample);

     <S extends T> long count(@NotNull Example<S> paramExample);

     <S extends T> boolean exists(@NotNull Example<S> paramExample);
}